let loginModule = (function () {
    let $userName = $('.userName'),
        $userPass = $('.userPass'),
        $submit = $('.submit');
    function handle() {
        $submit.click(async function () {
            let account = $userName.val().trim(),
                pass = $userPass.val().trim();
            // 格式校验
            if (account === '' || pass === '') {
                alert('账号或密码不能为空!');
            }
            // 给MD5加密
            pass = md5(pass);
            // 发送post请求
            let result = await axios.post('/user/login', {
                account: account,
                password: pass
            });

            if (parseInt(result.code) === 0) {
                alert('小主，您已登录成功，即将跳转至首页');
                window.location.href = './index.html';
                return;
            } else {
                alert('小主，您输入的密码账号不匹配，请重新输入~~')
            }

        })
    }

    return {
        init() {
            handle();
        }
    }
})();
loginModule.init();

// axios.get('/user/list',{
//     params:{
//         departmentId:0,
//         search:''
//     }
// }).then(res=>{
//     console.log(res);
// })